# coding:utf-8

import ddddocr
import os
from Automated_install_jdk import environment


def distinguish(path):
    ocr = ddddocr.DdddOcr(show_ad=False)
    name = os.listdir(path)
    for a in range(len(name)):
        with open(f"data//formal//{name[a]}", 'rb') as f:
            image = f.read()
        res = ocr.classification(image)
        if res == os.path.splitext(name[a])[0]:
            # name[a].split(".")[0]
            print(res)
        else:
            print(False, res, name[a])
        a += 1


if __name__ == '__main__':
    config_path = "config.yaml"
    path = environment.get_config(config_path)['path']
    distinguish(path)
